import React from 'react';
import { Input, message, Select,Modal } from 'antd';

import { PageContainer } from '@ant-design/pro-layout';
import InputItem from '@/components/InputItem';
import InnovationStudioController from '@/services/InnovationStudio/InnovationStudioController';
const {Option} = Select
const {confirm} = Modal
class UpdateStudio extends React.Component {
    constructor(props) {
        super(props);
        
        let userInfo = JSON.parse(sessionStorage.getItem("userInfo"))
        let datas={
           
            studioName:props.rows.studioName,
            description:props.rows.description,
        }
        this.state = { 
            studioCode:props.rows.studioCode,
            datas:datas,
            userInfo:userInfo
         };
    }
    componentDidMount(){
        this.props.onRef(this)
    }

    handleChange=(datas)=>{  
        this.setState({datas})
    }

    submit=()=>{
        let {datas,userInfo,studioCode}=this.state
        datas.userName=userInfo.userName
        datas.name=userInfo.name
        datas.studioCode=studioCode
        let that = this
        confirm({
            title:'提示',
            content:'确定要提交吗？',
            onOk(){
                InnovationStudioController.updateInfo(datas).then(r=>{
                    if(r&&r.status===200){
                        message.success('提交成功')
                        that.props.onCancel()
                    }
                })
            }
        })
        
    }

    render() {
        const {datas}=this.state
        const columns=[
            {name:'工作室名称',keyName:'studioName',valueType:'text',value:datas.studioName},
            {name:'工作室简介',keyName:'description',valueType:'textArea',value:datas.description},  
        ]
        return (
            <div>
                <InputItem columns={columns} onChange={this.handleChange}/>
            </div>
        );
    }
}

export default UpdateStudio;